home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / 4dostool / 4dtip2.zip / DO.DOC < prev    next >
Text File  |  1992-07-06  |  13KB  |  515 lines

  1. (Original documentation by Ray Tackett)
  2.  
  3.    The key to this batch file are the labels.  For example, there is a label
  4.    "chkdsk".  There is an alias "chdkdsk" which equals "do chkdsk".  The first
  5.    thing DO.BTM does is branch to the label defined in its first argument.
  6.    Thus, typing "chkdsk" on the command line expands to "do chkdsk" which
  7.    causes this batch file to branch to the "chkdsk" label.
  8.  
  9.    Having all the little batch files concentrated like this simplifies
  10.    maintenance, saves disk space (waste part of one cluster instead of many),
  11.    and allows the use of common subroutines.
  12.  
  13. @ECHO off
  14. if "%1" == "" goto help
  15.  
  16.               ^^^^^ That's the trick !
  17. goto %1
  18. quit
  19.  
  20. REM ───────────────────────────────────────────────── Help
  21. :help
  22. echo.
  23. echo Usage: DO function [options]
  24. echo.
  25. echo where function stands for
  26. echo.
  27. echo fullback - Full Backup
  28. echo incrback - Incremental Backup
  29. echo rest     - Restore
  30. echo.
  31. echo chkdsk   - Check disk
  32. echo vircheck - run virus checker (f-prot)
  33. echo.
  34. echo normal   - Reset to 4DOS environment
  35. echo.
  36. echo ho       - Set home directory / change to home directory
  37. echo.
  38. echo hack     - NetHack
  39. echo info     - shows some system information
  40. echo.
  41. quit
  42.  
  43. REM ───────────────────────────────────────────────── Disk oriented routines
  44.  
  45.   "fullback" makes a full backup of the hardisk.
  46.  
  47. REM ------------------------------------------------- Full Backup
  48. :fullback
  49.  
  50. setlocal
  51. unalias *
  52. set fg=%_fg
  53. set bg=%_bg
  54.  
  55.   save foreground and background color.
  56.  
  57. gosub GetDrive
  58.  
  59.   returns drive letter in %DRIVE%
  60.  
  61. color bright white on black
  62. echo Full Backup of Drive %DRIVE% named %@LABEL[%DRIVE%].
  63. color %fg on %bg
  64.  
  65. cd \
  66. gosub CleanUp
  67.  
  68.   deletes *.BAK files and temporary swap files etc.
  69.  
  70. gosub DoVirCheck /quick
  71.  
  72.   make a virus check before backuping.
  73.  
  74. :retry
  75. del /q \backup.log
  76. C:\DOS\backup %DRIVE% A: /s /l
  77.  
  78.   make the backup
  79.  
  80. set job=Backup
  81. gosub ReportSuccess
  82.  
  83.   and report whether it was successful.
  84.  
  85. if %YesNo% == Y GOTO retry
  86. endlocal
  87. quit
  88.  
  89. REM ------------------------------------------------- Incremental Backup
  90.  
  91.   The same game with an incremental backup...
  92.  
  93. :incrback
  94.  
  95. setlocal
  96. unalias *
  97. set fg=%_fg
  98. set bg=%_bg
  99.  
  100.   save foreground and background color.
  101.  
  102. gosub GetDrive
  103.  
  104.   returns drive letter in %DRIVE%
  105.  
  106. color bright white on black
  107. echo Incremental Backup of Drive %DRIVE% named %@LABEL[%DRIVE%].
  108. color %fg on %bg
  109.  
  110. gosub CleanUp
  111.  
  112.   deletes *.BAK files and temporary swap files etc.
  113.  
  114. gosub DoVirCheck /quick
  115.  
  116.   make a virus check before backuping.
  117.  
  118. C:\TOOLS\newfiles /tot %DRIVE%
  119.  
  120.   list new files and files that have been changed since last backup and
  121.   summarize their size. The idea is to get an impression how many disks
  122.   this backup will fill.
  123.   (You could use "dir %DRIVE%\ /kma:a..." if you don't have newfiles
  124.    or equivalent.)
  125.  
  126. :retry
  127. C:\DOS\backup %DRIVE% A: /m /s /a /l
  128.  
  129.   do the job
  130.  
  131. set job=Backup
  132. gosub ReportSuccess
  133.  
  134.   and report its success.
  135.  
  136. if %YesNo% == Y GOTO retry
  137. endlocal
  138. quit
  139.  
  140. REM ------------------------------------------------- Restore
  141.  
  142.   Restores a single file or a directory.
  143.  
  144. :rest
  145.  
  146. setlocal
  147. unalias *
  148. set fg=%_fg
  149. set bg=%_bg
  150.  
  151. gosub GetDrive
  152.  
  153. set DIRNAME=%@SUBSTR[%@FULL[%2],2,255]
  154. set DIR=%@UPPER[%@PATH[%DIRNAME%]]
  155. iff %@INDEX[%2,*] GE 0 .OR. %@INDEX[%2,?] GE 0 THEN
  156.  set ISAMBIG=Y
  157. else
  158.  set ISAMBIG=N
  159. endiff
  160.  
  161.   Get Directory name and/or file name(s).
  162.  
  163. color bright white on black
  164. echo Restoring %DRIVE%%DIRNAME%...
  165. color %fg on %bg
  166. iff %ISAMBIG%==Y then find /I "%DIR%" %DRIVE%\backup.log|more.com
  167.                  else find /I "%DIRNAME%" %DRIVE%\backup.log|more.com
  168. endiff
  169.  
  170.   and show the disk number(s) on which they have been stored.
  171.  
  172. color bright white on black
  173. echo Please insert appropriate disk.
  174. color %fg on %bg
  175.  
  176.  
  177. iff %ISAMBIG%=Y then C:\DOS\restore A: %DRIVE%%DIRNAME% /s /p
  178.                 else C:\DOS\restore A: %DRIVE%%DIRNAME% /p
  179. endiff
  180.  
  181.   restore the files..
  182.  
  183. set job=Restore
  184. gosub ReportSuccess
  185.  
  186.   ..and report the success.
  187.  
  188. endlocal
  189. quit
  190.  
  191.   The only use of this shortcut is to avoid typing a "N" when
  192.   lost clusters are detected.
  193.  
  194.  
  195. REM ------------------------------------------------- CHKDSK
  196. :chkdsk
  197.  
  198. gosub DoChkDsk
  199. quit
  200.  
  201.   Perform a virus check (by using F-PROT)
  202.  
  203. REM ------------------------------------------------- Virus Check
  204. :vircheck
  205. setlocal
  206. unalias *
  207. set fg=%_fg
  208. set bg=%_bg
  209.  
  210. gosub GetDrive
  211. gosub DoVirCheck
  212. endlocal
  213. quit
  214.  
  215. REM ─────────────────────────────────────────── Environment oriented routines
  216.  
  217.   Restore the normal configuration
  218.  
  219. REM ------------------------------------------------- Normal Environment
  220. :normal
  221. unset *
  222. set /r C:\4DOS\environ
  223. alias /r C:\4DOS\aliases
  224. echo 4DOS-Configuration read.
  225. quit
  226.  
  227.   Back to the home directory...
  228.  
  229. REM ------------------------------------------------- Home
  230. :ho
  231. iff "%2" == "" then
  232.  echos Changing to %@upper[%home%]...
  233.  cdd %home%
  234. else
  235.  setlocal
  236.  *set home=%@upper[%@full[%2]]
  237.  *unset /q tmp temp cmdline comspec
  238.  iff %@index[%@upper[%path],G:\] GE 0 then
  239.   *set path=%@substr[%path,4,255]
  240.  endiff
  241.  echo New Home directory will be: %home%.
  242.  *set > c:\4DOS\environ.
  243.  endlocal
  244.  *set /r C:\4DOS\environ.
  245. endiff
  246. quit
  247.  
  248. REM ─────────────────────────────────────────────────────────── Applications
  249.  
  250.   This "batch" file starts nethack.
  251.  
  252. REM ------------------------------------------------- NetHack
  253. :hack
  254. setlocal
  255. unalias *
  256.  
  257. iff "%2"=="" then C:\NETHACK\nhack
  258. else
  259.  iff "%4" == "c" then set term=ibmpc
  260.  elseiff "%4" == "m" then set term=ibmpc-mono
  261.  else
  262.   inkey /K"CM" /W5 [C]olor or [M]ono ? %%ask
  263.   set ask=%@UPPER[%ask]
  264.   iff "%ask" == "C" then set term=ibmpc
  265.                     else set term=ibmpc-mono
  266.   endiff
  267.  endiff
  268.  
  269.  IFF %@READY[G:] == 1 THEN
  270.   ECHO Installing NetHack on RamDisk G:
  271.   cdd g:\
  272.   except (4*.* acd.*) del /sxy G:\*.* >& NUL:
  273.   *md SAVE
  274.   cdd c:\NETHACK
  275.   set size=%@FILESIZE[C:\NETHACK\SAVE\SAVE2\%2.SAV,K]
  276.   iff "%size" GT "300" then
  277.    copy /q normhack.cnf nethack.cnf
  278.    set hackmode=0
  279.   elseiff "%size" GT "200" then
  280.    copy /q halfhack.cnf nethack.cnf
  281.    set hackmode=50
  282.   else
  283.    copy /q fullhack.cnf nethack.cnf
  284.    set hackmode=100
  285.   endiff
  286.  ELSE
  287.   copy /q normhack.cnf nethack.cnf
  288.   set hackmode=0
  289.  ENDIFF
  290.  
  291.  :restore
  292.  iff %hackmode=0 then
  293.   copy /q C:\NETHACK\SAVE\SAVE2\%2.SAV C:\NETHACK\SAVE
  294.  elseiff %hackmode=50  then
  295.   copy /q halfhack.cnf nethack.cnf
  296.   copy /q C:\NETHACK\SAVE\SAVE2\%2.SAV C:\NETHACK\SAVE
  297.  else
  298.   copy /q fullhack.cnf nethack.cnf
  299.   copy /q C:\NETHACK\SAVE\SAVE2\%2.sav G:\SAVE
  300.  endiff
  301.  :goon
  302.  C:\NETHACK\nhack %2-%3
  303.  
  304.  iff %hackmode% GT 50  then move /q G:\SAVE\%2.sav C:\NETHACK\SAVE\SAVE2
  305.                        else move /q C:\NETHACK\SAVE\%2.sav C:\NETHACK\SAVE\SAVE2
  306.  endiff
  307.  inkey /K"YN " /W5 Try again (Y/N) ? %%ask
  308.  set ask=%@UPPER[%ask]
  309.  iff "%ask" == "Y" .OR. "%ask" == " " then goto /I restore endiff
  310.  echo.
  311. endiff
  312. endlocal
  313. quit
  314.  
  315. REM ─────────────────────────────────────────────────────────── Jokes
  316.  
  317.   I have wrote this fragment to get an impression how to use 4DOS's
  318.   built-in functions.
  319.  
  320. :info
  321. setlocal
  322. set alias=%_alias
  323. unalias *
  324. set fg=%_fg
  325. set bg=%_bg
  326.  
  327. cls
  328. drawbox 0 0 %@eval[%_ROWS-1] %@eval[%_COLUMNS-1] 0 white on Cyan fill Cyan
  329. vscrput 10 0 black on white 4DOS INFO
  330. vscrput 10 %@eval[%_COLUMNS-1] black on white 4DOS INFO
  331.  
  332. drawbox 2 2 8 46 1 black on white fill white shadow
  333. color black on white
  334. screen 2 15 [Environment]
  335. screen 3  3 You are running
  336. scrput 3 19 red   on white 4DOS %_4VER
  337. screen 3 28 under
  338. scrput 3 34 red   on white %_DOS %_DOSVER
  339. screen 3 42 .
  340. screen 5 3  Free Environment Space : %_ENV Bytes
  341. screen 6 3  Free Alias       Space : %ALIAS Bytes
  342. iff %_ANSI == 0 then screen 7 3  ANSI.SYS not installed.
  343. elseiff %_ANSI == 1 then screen 7 3  ANSI.SYS will be supported.
  344. endiff
  345.  
  346. drawbox 2 49 8 75 1 bright yellow on green fill green shadow
  347. color bright yellow on green
  348. screen  2 59 [Hardware]
  349. screen  3 50 CPU        :
  350. scrput  3 63 bright white on green %_CPU
  351. screen  4 50 Coprocessor:
  352. scrput  4 63 bright